package designPattern.creationpattern.singleton;

/*饿汉式*/
public class HungerySingleton2 {

    // 1：构造私有
    private HungerySingleton2() {
    }

    // 2：定义静态成员变量
    private static HungerySingleton2 hungerySingleton2;

    // 3：静态代码块初始化
    static {
        hungerySingleton2 = new HungerySingleton2();
    }

    // 4：对外提供公共⽅法获取对象
    public static HungerySingleton2 getSingletonInstance() {
        return hungerySingleton2;
    }

}
